package com.example.night.controller;

import com.example.night.service.ApiService.yuantuitui.GoodService;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.concurrent.ExecutionException;

@RestController
@RequestMapping("/api/goods")
public class GoodsController {
    private final GoodService goodService;
    public GoodsController(GoodService goodService) {
        this.goodService = goodService;
    }

    @GetMapping("/get_goods")
    public Map<String, Object> getGoodsManagerData(
            @RequestParam int page,
            @RequestParam String search
    ) throws JsonProcessingException, ExecutionException, InterruptedException {

        return goodService.fetchGoods(page, search);
    }
}
